//
//  AppInstruction.m
//  XPhoto
//
//  Created by sentinel on 2020/4/3.
//  Copyright © 2020 baboy. All rights reserved.
//

#import "AppInstruction.h"
#import <BKKit/BKApi.h>
#import <BKKit/HttpResponse.h>

@implementation AppInstruction
- (NSString *)lang:(NSString *)lang{
    if ([@"en" isEqualToString:lang]) {
        return self.en?:self.text;
    }
    return self.zh?:self.text;
}

+ (id)searchWithKey:(NSString *)key
           callback:(void(^)(id task, id response, NSError *error))callback{
    return [BKApi request:API_INSTRUCTION_SEARCH_BY_KEY
               parameters:@{@"key":key}
                 callback:^(id  _Nonnull task, id  _Nullable json, NSError * _Nullable error) {
        id instruction = nil;
        if (!error) {
            HttpResponse *response = [HttpResponse responseWithDictionary:json dataItemClass:[AppInstruction class]];
            if ([response isSuccess]) {
                instruction = response.data;
            }
            if(![response isSuccess]){
                error = [NSError errorWithDomain:HttpRequestDomain code:response.status userInfo:@{NSLocalizedDescriptionKey:response.msg}];
            }
        }
        if (callback) {
            callback(task, instruction, error);
        }
    }];
}
@end

@implementation AppInstructionSearchArgs



@end
